package cn.micai.queue;

import javafx.concurrent.Task;

import java.util.concurrent.BlockingQueue;

public class TaskRunnable implements Runnable {

    BlockingQueue<Task> queue;

    @Override
    public void run() {
        try {
            processTask(queue.take());
        } catch (InterruptedException e) {
            // 恢复中断状态，避免掩盖中断
            Thread.currentThread().interrupt();
        }
    }

    private void processTask(Task task) {
        System.out.println(task.toString());
    }
}
